#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


int main()
{
   umask(0); 
   //一次创建四个文件
   int fd1 = open("log1.txt", O_WRONLY|O_CREAT|O_APPEND, 0666);
   int fd2 = open("log2.txt", O_WRONLY|O_CREAT|O_APPEND, 0666);
   int fd3 = open("log3.txt", O_WRONLY|O_CREAT|O_APPEND, 0666);
   int fd4 = open("log4.txt", O_WRONLY|O_CREAT|O_APPEND, 0666);
   if(fd1 < 0)
   {
       printf("open file error\n");
       return 1;
   }
   //打印这四个文件描述符观察其逻辑
   printf("fd1: %d\n", fd1);
   printf("fd2: %d\n", fd2);
   printf("fd3: %d\n", fd3);
   printf("fd4: %d\n", fd4);

    return 0;
}